entry: Only set one of the .left, .right style classes
authorMatthias Clasen <mclasen@redhat.com>
Mon, 26 Oct 2015 19:28:50 +0000 (15:28 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 26 Oct 2015 19:28:50 +0000 (15:28 -0400)
We were not removing the old style class when adding a new one.

gtk/gtkentry.c

index 75e0131ec14c3a6347e331035c7574eac1f3dffe..206b42f926f64bc9138ed3f2a05b3e379212e243 100644 (file)
@@ -3169,25 +3169,16 @@ update_icon_style (GtkWidget            *widget,
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
   EntryIconInfo *icon_info = priv->icons[icon_pos];
-  const gchar *side;
+  const gchar *sides[2] = { GTK_STYLE_CLASS_LEFT, GTK_STYLE_CLASS_RIGHT };
 
   if (icon_info == NULL)
     return;
 
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-    {
-      side = icon_pos == GTK_ENTRY_ICON_PRIMARY
-             ? GTK_STYLE_CLASS_RIGHT
-             : GTK_STYLE_CLASS_LEFT;
-    }
-  else
-    {
-      side = icon_pos == GTK_ENTRY_ICON_PRIMARY
-             ? GTK_STYLE_CLASS_LEFT
-             : GTK_STYLE_CLASS_RIGHT;
-    }
+    icon_pos = 1 - icon_pos;
 
-  gtk_css_node_add_class (icon_info->css_node, g_quark_from_static_string (side));
+  gtk_css_node_add_class (icon_info->css_node, g_quark_from_static_string (sides[icon_pos]));
+  gtk_css_node_remove_class (icon_info->css_node, g_quark_from_static_string (sides[1 - icon_pos]));
 }
 
 static EntryIconInfo*